package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.SysDictItem;
import com.ruoyi.system.input.SysDictInput;
import com.ruoyi.system.service.ISysDictItemService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 *
 * @author lth
 * @date 2023-12-13
 */
@RestController
@RequestMapping("/dangerControl/item")
public class SysDictItemController extends BaseController
{
    @Autowired
    private ISysDictItemService sysDictItemService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:item:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysDictItem sysDictItem)
    {
        startPage();
        List<SysDictItem> list = sysDictItemService.selectSysDictItemList(sysDictItem);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:item:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysDictItem sysDictItem)
    {
        List<SysDictItem> list = sysDictItemService.selectSysDictItemList(sysDictItem);
        ExcelUtil<SysDictItem> util = new ExcelUtil<SysDictItem>(SysDictItem.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:item:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(sysDictItemService.selectSysDictItemById(id));
    }

    /**
     * 新增【请填写功能名称】
     */

    @PreAuthorize("@ss.hasPermi('dangerControl:item:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysDictItem sysDictItem)
    {
        return toAjax(sysDictItemService.insertSysDictItem(sysDictItem));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:item:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysDictItem sysDictItem)
    {
        return toAjax(sysDictItemService.updateSysDictItem(sysDictItem));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:item:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(sysDictItemService.deleteSysDictItemByIds(ids));
    }



    /**     查询隐患等级
     * @Author lth
     * @Description //TODO
     * @Date 9:18 2023/12/14
     * @Param
     * @return
     **/
    @PreAuthorize("@ss.hasPermi('dangerControl:standard:query')")
    @GetMapping("/getDangerLevel")
    public TableDataInfo getDangerLevel(@RequestBody SysDictInput input){
        startPage();
        List<SysDictItem> list = sysDictItemService.getDangerLevel(input);
        return getDataTable(list);
    }


    /**     查询风险等级
    * @Author lth
    * @Description //TODO
    * @Date 15:45 2023/12/15
    * @Param
    * @return
     **/
    @PreAuthorize("@ss.hasPermi('dangerControl:standard:query')")
    @GetMapping("/getRiskLevel")
    public TableDataInfo getRiskLevel(@RequestBody SysDictItem sysDictItem){
        startPage();
        List<SysDictItem> list = sysDictItemService.getRiskLevel(sysDictItem);
        return getDataTable(list);
    }


    /**     查询危险源状态
    * @Author lth
    * @Description //TODO       dictid与数据中不对应
    * @Date 9:30 2023/12/18
    * @Param
    * @return
     **/
//    @PreAuthorize("@ss.hasPermi('dangerControl:standard:query')")
//    @GetMapping("/getRiskLevel")
//    public TableDataInfo getRiskLevel(@RequestBody SysDictItem sysDictItem){
//        startPage();
//        List<SysDictItem> list = sysDictItemService.getRiskLevel(sysDictItem);
//        return getDataTable(list);
//    }



    /**     查询三违volation_category volation_level列表
    * @Author lth
    * @Description //TODO
    * @Date 16:41 2023/12/18
    * @Param
    * @return
     **/
//    @PreAuthorize("@ss.hasPermi('dangerControl:standard:query')")
//    @GetMapping("/getCategoryList")
//    public TableDataInfo getCategoryList(@RequestBody SysDictItem sysDictItem){
//        startPage();
//        List<SysDictItem> list = sysDictItemService.getRiskLevel(sysDictItem);
//        return getDataTable(list);
//    }








    /**
     * 获取项目列表名称
     * @param input
     * @return
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:item:query')")
    @GetMapping("/getItemList")
    public TableDataInfo getItemList(SysDictInput input) {
        startPage();
        List<SysDictItem> list = sysDictItemService.getVentilationName(input);
        return getDataTable(list);
    }
}
